--- 'https://github.com/Frege/frege/issues/355 Issue #355'
--- Type checking aborts with "bad types in unification" with @(extends Object)@ construct
module tests.comp.Issue355 where

native forN java.lang.Class.forName :: String -> IO (Class (≤Object)) throws ClassNotFoundException


-- frege> forN "java.lang.Object"
-- IO (Class (≤Object))

idc :: Class (≤Object) -> IO (Class Object)
idc x = pure x

idx x = pure x

value1 :: IO (Class Object)
value1 = (forN "java.lang.Object") >>= idx

value2 = forN "java.lang.Object" >>= idc

main :: IO Bool
main = do
    value1 >>= println . _.getName
    value2 >>= println . _.getName
    pure true